<template>
  <el-dialog
    :title="$t('domainlist.addSite')"
    :visible="visible"
    width="90%"
    custom-class="addsite-dialog"
    @close="handleClose"
  >
    <el-form :model="site" label-width="80px">
      <el-form-item :label="$t('domainlist.domain')">
        <el-input v-model="site.host" placeholder="例如：example.com" />
      </el-form-item>
      <el-form-item :label="$t('domainlist.dirpath')">
        <el-input v-model="site.dirpath" placeholder="可选，默认无" />
      </el-form-item>
    </el-form>

    <template #footer>
      <el-button @click="handleClose">{{ $t('domainlist.cancel') }}</el-button>
      <el-button type="primary" @click="confirm">{{ $t('domainlist.confirm') }}</el-button>
    </template>
  </el-dialog>
</template>

<script>
export default {
  name: 'AddSiteDialog',
  props: {
    visible: Boolean,
    site: {
      type: Object,
      default: () => ({ host: '', dirpath: '' })
    }
  },
  methods: {
    confirm() {
      this.$emit('confirm', this.site)
    },
    handleClose() {
      this.$emit('update:visible', false)
      this.$emit('close')
    }
  }
}
</script>

  <style>
.addsite-dialog {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
</style>
